package com.anysoft.web;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.KeyEvent;
import android.webkit.WebView;

import com.anysoft.event.TimeOutEvent;
import com.anysoft.me.base.BaseWebViewActivity;
import com.anysoft.utils.CommonUtil;
import com.anysoft.utils.HttpUtils;
import com.anysoft.utils.MentorLogger;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * 资产-智慧
 * Created by wyb on 2017/4/8.
 */

public class AssetsActivity extends BaseWebViewActivity {

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        isShowTitleBar(false);
        title.setText("工银智投");
        generateUrl("assets",HttpUtils.getCommonParams2StringByWeb(mActivity)
                + "&shareClass=A&cusNo=" + getFundCustomerNo());
        if (CommonUtil.isNetWorkConnected(this)) {
            setWebViewConfig(loadUrl);
        }
    }


    public void onshouldOverrideUrlLoadingCallBack(WebView webview, String url) {
        MentorLogger.Log(TAG, "url=" + url);

        if (url.contains("prompt.html")) {
            mIntent.setClass(mActivity, SelectWarmPromptActivity.class);
            mIntent.putExtra("url", url);
            startActivity(mIntent);
        } else if (url.contains("10.0.0.1")) {
            this.finish();
        } else if (url.contains("riskQuestion.html")) {
            startRiskActivity(null);
        } else {
            webview.loadUrl(url);
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onTimeOutCallBack(TimeOutEvent event) {
        if (event.isSuccess) {
            finish();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
